﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>btable</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/css/btable.css" />
    <script src="/static/js/inout/jquery-1.8.2.min.js"></script>
</head>

<body style=" background-color: gainsboro;">
    <div style="margin:0px; background-color: white; margin:0 10px;">
        <blockquote class="layui-elem-quote" style="height: 31px;">

        </blockquote>
        <div id="content" style="width: 100%;height: 533px;"></div>
        <div id="demo7"></div>
    </div>

    <script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/static/js/',
            v: new Date().getTime()
        }).use(['btable', 'form','paging'], function () {
            var btable = layui.btable(),
                $ = layui.jquery,
                layerTips = parent.layer === undefined ? layui.layer : parent.layer, //获取父窗口的layer对象
                layer = layui.layer,//获取当前窗口的layer对象;
                form = layui.form();

            btable.set({
                openWait: true,//开启等待框
                elem: '#content',
                url: '/admin/lerrtyer/seleclit', //数据源地址
                pageSize: 10,
                params: {
                    t: new Date().getTime() //额外的请求参数
                },
                columns: [{ //配置数据列
                    fieldName: '标题', //显示名称
                    field: 'numbtitle', //字段名
                    sortable: true //是否显示排序
                },{
                    fieldName: '创建时间',
                    field: 'addTime',
                    sortable: true
                },{
                    fieldName: '修改时间',
                    field: 'updateTime',
                    format: function (id, obj) {
                        //id
                        //行数据对象
                        //返回值：格式化的纯文本或html文本
                        return obj.sign;
                    }
                },{
                    fieldName: '操作',
                    field: 'id',
                    format: function (val,obj) {
                        var html = '<input type="button" value="修改" id="edit" data-action="edit" data-title="'+obj.title+'" data-id="'+val+'" class="layui-btn layui-btn-mini" />';
                        return html;
                    }
                }],
                even: true,//隔行变色
                field: 'id', //主键ID
                //skin: 'row',
                checkbox: false,//是否显示多选框
                paged: true, //是否显示分页
                singleSelect: false, //只允许选择一行，checkbox为true生效
                onSuccess: function ($elem) { //$elem当前窗口的jq对象
                    $elem.children('tr').each(function () {
                        $(this).children('td:last-child').children('input').each(function () {
                            var $that = $(this);
                            var action = $that.data('action');
                            var id = $that.data('id');
                            var title = $that.data('title');
//                            var curl = $that.data('bd');
                            $that.on('click', function () {
                                switch (action) {
                                    case 'edit':
                                        window.location.href="/admin/lerrtyer/edit?id="+id;
                                        break;
                                }
                            });
                        });
                    });
                }
            });

            btable.render();
            //监听搜索表单的提交事件
            form.on('submit(search)', function (data) {
                btable.get(data.field);
                return false;
            });
            $(window).on('resize', function (e) {
                var $that = $(this);
                $('#content').height($that.height() - 92);
            }).resize();
        });
    </script>
</body>

</html>